<?php
/**
 * Created by PhpStorm.
 * User: WYJ
 * Date: 2018/7/12
 * Time: 14:23
 */

namespace zhtfrontend\modules\customermanage\components\services;

use common\components\helpers\Fun;
use yii\db\Query;

class Cmutil
{

    public static function getCategory($id)
    {
        $title = 'null';
        if (isset($id)) {
            $cate = (new Query())->select('*')->from('{{%cate}}')
                ->where(['id' => $id])->one();
            $title = isset($cate) ? $cate['name'] : 'null';
        }
        return $title;
    }

    public static function getAdmin($id)
    {
        $title = 'null';
        if (isset($id)) {
            $admin = (new Query())->select('*')->from('{{%admin}}')
                ->where(['id' => $id])->one(Fun::getSiteDb());
            $title = (isset($admin)) ? $admin['name'] : 'null';
        }
        return $title;
    }

    public static function getStatus($val)
    {
        switch ($val) {
            case '0':
                return \Yii::t('zhtfrontend', '潜在客户');
            case '1':
                return \Yii::t('zhtfrontend', '意向客户');
            case '2':
                return \Yii::t('zhtfrontend', '意向可转化客户');
            case '3':
                return \Yii::t('zhtfrontend', '普通会员');
            case '4':
                return \Yii::t('zhtfrontend', '正式VIP');
            case '':
                return \Yii::t('zhtfrontend', '意向客户');

        }
    }

    public static function getFollowStatus($val)
    {
        switch ($val) {
            case '0':
                return \Yii::t('zhtfrontend', '可跟进');
            case '1':
                return \Yii::t('zhtfrontend', '不可跟进');
            case '3':
                return \Yii::t('zhtfrontend', '已回收');
        }
    }

    public static function getSource($val)
    {
        switch ($val) {
            case '1':
                return \Yii::t('zhtfrontend', '电话');
            case '2':
                return \Yii::t('zhtfrontend', '地推');
            case '3':
                return \Yii::t('zhtfrontend', '其他');
            case null:
                return \Yii::t('zhtfrontend', '暂无');
            case '0':
                return \Yii::t('zhtfrontend', '暂无');
        }
    }

}